Ext.define('PackageManager.store.ComponentStore', {
    extend: 'Ext.data.Store',
    model: 'PackageManager.model.Component',


    autoSync: true,

   proxy: {
       type: 'memory',
        reader: {
            type: 'array',
            root: 'components'
        }
    },
    listeners: {
        beforesync : function() {

            var updatedRecords = Ext.data.StoreManager.lookup('ComponentStore').getUpdatedRecords();
            var fullStore = Ext.data.StoreManager.lookup('PackageStoreFull');

            var store = Ext.data.StoreManager.lookup('PackageStore');


            console.log(updatedRecords[0].data);

            var fullRecord = Ext.create('PackageManager.model.PackageModelFull', {
                id: store.getAt(0).data.id,
                stage: store.getAt(0).data.stage,
                components: [updatedRecords[0].data],
                staticDatas:[]
            });
            console.log('123123');
            console.log(fullRecord);

            fullRecord.setDirty();
            fullStore.add(fullRecord);


            fullStore.sync();

            this.commitChanges();
            Ext.getCmp('griddy').getView().refresh();
        }
    }


});